package com.netbao.ins.controller;

import com.netbao.ins.model.Insurance;
import com.netbao.ins.service.InsuranceService;
import com.netbao.model.PageBean;
import com.netbao.model.PageResult;
import com.netbao.model.Result;
import com.netbao.sys.model.Dict;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author Duanps
 * @create 2019-11-04 19:35
 */
@Controller
@RequestMapping("/ins")
public class InsuranceController {
    @Autowired
    private InsuranceService insuranceService;

    @GetMapping("/page")
    private String page() {
        return "/ins/insurance";
    }

    @GetMapping("/all")
    @ResponseBody
    public PageResult findAll(PageBean pageBean, String cno, String idCard) {
        return insuranceService.findAll(pageBean, cno, idCard);
    }

    @RequestMapping("/getInsuList")
    @ResponseBody
    public List<Insurance> getInsuList() {
        return insuranceService.getInsuList();
    }

    @ResponseBody
    @RequestMapping("/getInsuListData")
    public Result getInsuListData(Integer id) {
        return insuranceService.getInsuListData(id);
    }

    @ResponseBody
    @RequestMapping("/getInsurancecycle")
    public List<Dict> getInsurancecycle() {
        return insuranceService.getInsuranceYear();
    }

    @ResponseBody
    @RequestMapping("/getInsuranceType")
    public List<Dict> getInsuranceType() {
        return insuranceService.getInsuranceType();
    }

    @ResponseBody
    @RequestMapping("/getInsuranceCompany")
    public List<Dict> getInsuranceCompany() {
        return insuranceService.getInsuranceCompany();
    }

    @ResponseBody
    @RequestMapping("/addInsuranInfo")
    public Result addInsuranInfo(Insurance insurance) {
        return insuranceService.addInsInfo(insurance);
    }

    @ResponseBody
    @PostMapping("/delete")
    public Result delete(Long id) {
        System.out.println(id);
        return insuranceService.delete(id);
    }
}
